package com.itlong.cloud.commons.chinapay;

import com.itlong.cloud.equip.commons.IPushCloudElevatorChangeLogServiceClient;
import com.itlong.cloud.paymenthub.IChinaPayTransferAccountServiceClient;
import com.itlong.cloud.utils.date.DateUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;

/**
 * <desc>
 *      银联交易结果状态任务调度类
 * </desc>
 *
 * @createDate 2018/09/25
 */
@EnableScheduling // 启用定时任务
@RestController
public class ChinaPayTradeStatusTimeTask {
    private static Logger LOG = LoggerFactory.getLogger(ChinaPayTradeStatusTimeTask.class);

    @Autowired
    IChinaPayTransferAccountServiceClient iChinaPayTransferAccountServiceClient;

    /**
     * <desc>
     *      查询银联交易结果状态定时任务
     * </desc>
     *
     * @author Juguang.S
     * @creatDate 2018/04/03
     */
    @Scheduled(cron = "0 */30 * * * ?") // 每30分钟执行一次
    //@Scheduled(cron = "0 */5 * * * ?")  //每10分钟执行一次
    public void timeTaskSychro() {
        try {
            iChinaPayTransferAccountServiceClient.timeTaskGetOrderStatus();
//            LOG.info("【定时任务】查询银联交易结果状态定时任务执行成功，当前时间：" + DateUtil.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            LOG.error("【定时任务】查询银联交易结果状态定时任务执行失败，当前时间：" + DateUtil.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss:"),e);
        }
    }
}
